#ifndef OMG_DDS_EXCEPTION_HPP_
#define OMG_DDS_EXCEPTION_HPP_

/* Copyright (c) 2009-2010, Real-Time Innovations, Inc.
 * Copyright (c) 2010, Object Management Group, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the names of the above copyright holders nor the names of their
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL A COPYRIGHT HOLDER OR CONTRIBUTOR BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


// Don't extend std::exception: std::*_error extend it non-virtually.
class dds::core::Exception
{
protected:
    Exception();
    Exception(const Exception& src);

public:
    virtual ~Exception() throw ();

public:
    virtual const char* what() const throw () = 0;
};


class dds::core::Error : public Exception, public std::exception
{
protected:
    explicit Error(const std::string& msg);
    Error(const Error& src);
    
public:
    virtual ~Error() throw ();

public:
    virtual const char* what() const throw ();
};


class dds::core::AlreadyClosedError :
    public Exception,
    public std::logic_error
{
protected:
    explicit AlreadyClosedError(const std::string& msg);
    AlreadyClosedError(const AlreadyClosedError& src);
    
public:
    virtual ~AlreadyClosedError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::IllegalOperationError :
    public Exception,
    public std::logic_error
{
protected:
    explicit IllegalOperationError(const std::string& msg);
    IllegalOperationError(const IllegalOperationError& src);
    
public:
    virtual ~IllegalOperationError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::ImmutablePolicyError :
    public Exception,
    public std::logic_error
{
protected:
    explicit ImmutablePolicyError(const std::string& msg);
    ImmutablePolicyError(const ImmutablePolicyError& src);
    
public:
    virtual ~ImmutablePolicyError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::InconsistentPolicyError :
    public Exception,
    public std::logic_error
{
protected:
    explicit InconsistentPolicyError(const std::string& msg);
    InconsistentPolicyError(const InconsistentPolicyError& src);
    
public:
    virtual ~InconsistentPolicyError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::InvalidArgumentError :
    public Exception,
    public std::invalid_argument
{
protected:
    explicit InvalidArgumentError(const std::string& msg);
    InvalidArgumentError(const InvalidArgumentError& src);
    
public:
    virtual ~InvalidArgumentError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::NotEnabledError :
    public Exception,
    public std::logic_error
{
protected:
    explicit NotEnabledError(const std::string& msg);
    NotEnabledError(const NotEnabledError& src);
    
public:
    virtual ~NotEnabledError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::OutOfResourcesError :
    public Exception,
    public std::runtime_error
{
protected:
    explicit OutOfResourcesError(const std::string& msg);
    OutOfResourcesError(const OutOfResourcesError& src);
    
public:
    virtual ~OutOfResourcesError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::PreconditionNotMetError :
    public Exception,
    public std::logic_error
{
protected:
    explicit PreconditionNotMetError(const std::string& msg);
    PreconditionNotMetError(const PreconditionNotMetError& src);
    
public:
    virtual ~PreconditionNotMetError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::TimeoutError :
    public Exception,
    public std::runtime_error
{
protected:
    explicit TimeoutError(const std::string& msg);
    TimeoutError(const TimeoutError& src);
    
public:
    virtual ~TimeoutError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::UnsupportedError :
    public Exception,
    public std::logic_error
{
protected:
    explicit UnsupportedError(const std::string& msg);
    UnsupportedError(const UnsupportedError& src);
    
public:
    virtual ~UnsupportedError() throw ();
    
public:
    virtual const char* what() const throw ();
};


class dds::core::InvalidDataError :
    public Exception,
    public std::logic_error
{
protected:
    explicit InvalidDataError(const std::string& msg);
    InvalidDataError(const UnsupportedError& src);
    
public:
    virtual ~InvalidDataError() throw ();
    
public:
    virtual const char* what() const throw ();
};


#endif // !defined(OMG_DDS_EXCEPTION_HPP_)
